import { createApp } from 'vue'
import App from './App.vue'
import './index.css'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/lib/theme-chalk/index.css'
import axios from 'axios'
import VueAxios from 'vue-axios'
import store from './store'
import Tool from './util/tool'


axios.defaults.baseURL=import.meta.env.VITE_APP_SERVER

/**
 * axios拦截器
 */
 axios.interceptors.request.use(function (config) {
    console.log('请求参数：', config);
    const token =store.state.user.token;
    if(Tool.isNotEmpty(token)){
      config.headers.token=token;
      console.log("请求headers增加token：",token)
    }
    return config;
  }, error => {
    return Promise.reject(error);
  });
  axios.interceptors.response.use(function (response) {
    console.log('返回结果：', response);
    return response;
  }, error => {
    console.log('返回错误：', error);
    return Promise.reject(error);
  });
  
createApp(App).use(VueAxios,axios).use(router).use(store).use(ElementPlus).mount('#app')
console.log('环境：',import.meta.env.VITE_NODE_ENV)
console.log('服务端：',import.meta.env.VITE_APP_SERVER)